﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SmsVotes.DataAccess;

namespace SmsVotes.SmsVoting
{
    public partial class VoteHistory : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var voteState = StateManager.GetVoteStateByID(Convert.ToInt32(Request.QueryString["sid"]));
            voteState.Vote.Questions.SmartLoad(voteState.Vote);

            lbVoteName.Text = voteState.Vote.Name;
            lbTotalVotes.Text = (from answerState in voteState.AnswerStates
                            select answerState.Votes).Sum().ToString();

            lvQuestions.DataSource = voteState.Vote.Questions;
            lvQuestions.DataBind();
        }
    }
}